// index.js
const {getBanner,getGoods}=require("../../api/index")
Page({
    data:{
       swiperOptions:{
          indicatorDots:true,
          autoplay:true,
          swiperData:[]
       },
       page:1,
       navData:[
        {
            text:"数码",
            icon:"like",
            color:"#ff0000"
       },
       {
            text:"生鲜",
            icon:"star",
            color:"#ff0000"
        },
        {
            text:"数码",
            icon:"like",
            color:"#ff0000"
        },
        {
            text:"优惠",
            icon:"gift",
            color:"#ff0000"
        },
        {
            text:"充值",
            icon:"phone",
            color:"#ff0000"
        },
        {
            text:"领券",
            icon:"gem",
            color:"#ff0000"
        },
        {
            text:"外卖",
            icon:"gift-card",
            color:"#ff0000"
        },
        {
            text:"美食",
            icon:"smile",
            color:"#ff0000"
        },
       ]
    },
    onLoad(){
        getBanner().then(res =>{
            console.log(res.data);
            this.setData({
               swiperData:res.data.data.result
            })
        }),
        this.http(this.data.page)
    },
    http(page){
        getGoods({page}).then(res =>{
            console.log(res.data);
            this.setData({
                goodsData:res.data.data.result
             })
        })
    },
    clickSearch(){
        console.log("获得焦点")
        wx.navigateTo({
          url: '/pages/search/search',
        })
    }
})
